package com.heima.minio;

import io.minio.MinioClient;
import io.minio.PutObjectArgs;

import java.io.FileInputStream;

public class MinioTest {
    public static void main(String[] args)  throws Exception {
        try {
            // 1、创建minio连接客户端
            MinioClient minioClient = MinioClient.builder().credentials("minio", "minio123")
                    .endpoint("http://192.168.200.131:9000")
                    .build();

            // 2、上传
            FileInputStream fileInputStream = new FileInputStream("D:\\图片\\soac5reejh4.jpg");
            PutObjectArgs putObjectArgs = PutObjectArgs.builder()
                    .object("hello.jpg")
                    .contentType("image/jpg")
                    .bucket("leadnews")
                    .stream(fileInputStream, fileInputStream.available(), -1)
                    .build();


            minioClient.putObject(putObjectArgs);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
